package com.pp.main;

import java.awt.Dimension;

import javax.media.opengl.awt.GLCanvas;
import javax.swing.JFrame;

import com.jogamp.opengl.util.FPSAnimator;
import com.pp.constant.Constants;
import com.pp.constant.Strings;
import com.pp.scene.GraphicListener;
import com.pp.stop.AnimatorStopper;

public class Main {

    public static void main(String[] args) {

	Dimension prefferedDimension = new Dimension(
		Constants.CANVAS_WIDTH.getValue(),
		Constants.CANVAS_HEIGHT.getValue());

	GLCanvas toPaintOn = new GLCanvas();
	toPaintOn.setPreferredSize(prefferedDimension);

	GraphicListener listener = new GraphicListener();
	toPaintOn.addGLEventListener(listener);

	FPSAnimator displayCaller = new FPSAnimator(toPaintOn,
		Constants.FPS.getValue(), true);

	JFrame theFrame = new JFrame();
	theFrame.getContentPane().add(toPaintOn);
	theFrame.addWindowListener(new AnimatorStopper(displayCaller));
	theFrame.setTitle(Strings.TITLE.getValue());
	theFrame.pack();
	theFrame.setVisible(true);

	displayCaller.start();
    }
}
